﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FightTheDragon.Interface
{
    interface FontEffects
    {
        void Init(Text T);
        void ApplyEffect(Text T);

    }
    class NoEffect : FontEffects
    {
        void FontEffects.Init(Text T)
        {

        }
        void FontEffects.ApplyEffect(Text T)
        {

        }
    }
    class RandEffect : FontEffects
    {
        private char[] Decode;
        private string m_BufferText;
        public string BufferText
        {
            get { return m_BufferText; }
            set { m_BufferText = value; }
        }

        void FontEffects.Init(Text T)
        {
            m_BufferText = T.TextToDisplay;
            Decode = new char[m_BufferText.Length];
        }
        void FontEffects.ApplyEffect(Text T)
        {
            Random Rand = new Random();
            int Length = BufferText.Length;
            for (int x = 0; x < Length; x++)
            {
                char Check = (char)Rand.Next(32, 126);
                if (Decode[x] == BufferText[x])
                    continue;
                else if (BufferText[x] == '\n')
                    Decode[x] = BufferText[x];
                else
                    Decode[x] = Check;



            }
            T.TextToDisplay = new string(Decode);

        }
    }
    class RotateEffect : FontEffects
    {
        private bool m_RotateOnce;
        public bool RotateOnce
        {
            get { return m_RotateOnce; }
            set { m_RotateOnce = value; }
        }
        public RotateEffect(bool OneTimeRotation)
        {
            m_RotateOnce = OneTimeRotation;
        }
        void FontEffects.Init(Text T)
        {

        }

        void FontEffects.ApplyEffect(Text T)
        {
            if (!m_RotateOnce)
                T.Rotate += T.RotationRate;
            else if (m_RotateOnce && T.Rotate < 360)
                T.Rotate += T.RotationRate;
        }

    }
}
